export const login_mixin = {
    data() {
        return {
            loginData: {
                username: 'admin',
                password: '111111',
                remember: false
            },
            loginRule: {
                account: [{required: true, message: '请输入用户', trigger: 'blur'},],
                password: [{required: true, message: '请输入密码', trigger: 'blur'},],
            },
        };
    },

    methods: {
        loginAuth() {
            let loginParam = this.$utils.lodash.clone(this.loginData, true)
            if (loginParam.password && loginParam.password.length > 0) {
                loginParam.password = this.$utils.cryptojs.MD5(loginParam.password).toString();
            } else {
                delete loginParam.password
            }

            this.$security.oauth.login(loginParam).then(response => {
                if (response.bool) {
                    let redirect = this.$route.query.redirect
                    this.$router.push(redirect ? redirect : "/")
                }
            }).catch(error => {
                if (this.logon_mode == 'web') {
                    this.changedVerifyCodeUrl()
                }
            })
        },
    },
}